import il.technion.math.zipfdistribution.EfficentZipfDistribution;

import org.junit.Test;

public class ZipfTester {
	@Test
	public void testIt() {
		final int size = 100000;
		final Integer[] results = new Integer[size + 1];
		final EfficentZipfDistribution ezd = new EfficentZipfDistribution(0.9, size, 378123);

		for (int i = 0; i < (size + 1); i++)
			results[i] = new Integer(0);

		for (int i = 0; i < (size + 1) * 1000; i++)
			results[ezd.Sample()]++;

		for (int i = 1; i < 500; i++)
			System.out.println(i + ": " + results[i] / 1000);
		System.err.println(ezd.getSum());

	}
	@Test
	public void rankTest() {
		final EfficentZipfDistribution ezd = new EfficentZipfDistribution(0.8, 100000, 321);
		final double[] hist = new double[100000];
		for (int i = 0; i < 100000; i++)
			hist[ezd.Sample()]++;
		double max = 0.0;
		for (int i = 0; i < 100000; i++){
			if (hist[i] > max)
				max = hist[i];
		}
		final double alpha1 = Math.log10(hist[1] / hist[2]) / (Math.log10(2.0));
		System.out.println(hist	[1] + " " + hist[2]);
		System.out.println(alpha1);
		final double alpha2 = Math.log10(hist[1] / hist[3]) / (Math.log10(3.0));
		System.out.println(hist[1] + " " + hist[3]);
		System.out.println(alpha2);
		final double alpha3 = Math.log10(hist[1] / hist[4]) / (Math.log10(4.0));
		System.out.println(hist[1] + " " + hist[4]);
		System.out.println(alpha3);
		final double alpha4 = Math.log10(hist[1] / hist[5]) / (Math.log10(5.0));
		System.out.println(hist[1] + " " + hist[5]);
		System.out.println(alpha4);
		final double alpha5 = Math.log10(hist[1] / hist[6]) / (Math.log10(6.0));
		System.out.println(hist[1] + " " + hist[6]);
		System.out.println(alpha5);
	}
}
